﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;
using System.Web.Security;

public partial class Login : BasePage
{
   

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        UserDAO daoUser = new UserDAO();
        if (daoUser.CheckAccount(txtUsername.Text, txtPassword.Text))
        {
         
            FormsAuthentication.SetAuthCookie(txtUsername.Text, true);
           if (FormsAuthentication.GetRedirectUrl(txtUsername.Text, true).EndsWith("default.aspx"))
               Response.Redirect("Default.aspx");
           else
               Response.Redirect("Default.aspx");
        }
        else
        {  
            lbMessage.Text = "Username or password is incorrect";
        }
    }
}